package co.com.web;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import co.com.ejb.singleton.SingletonSessionBeanLocal;
import co.com.ejb.stateful.ShoppingCartBeanLocal;

/**
 * Servlet implementation class SingletonServlet
 */
@WebServlet(name = "Singleton", urlPatterns = { "/Singleton" })
public class SingletonServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@EJB
	SingletonSessionBeanLocal bean;
    /**
     * Default constructor. 
     */
    public SingletonServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name = request.getParameter("name");
		try {
			bean.greet(name);
		} catch (TimeoutException e) {
			System.err.println("Sorry, we are busy right now");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
